package exception;

import java.io.FileOutputStream;
import java.io.IOException;

public class FinallyDemo3 {
    public static void main(String[] args) {
        FileOutputStream fos = null;
        try{
            fos= new FileOutputStream("z:./data.dat");
            fos.write(1);
        }catch (IOException e)
        {
            System.out.println("error");
        }
        finally {
            try{
                if(fos!=null)
                    fos.close();
            }
            catch (IOException e)
            {
                e.printStackTrace();
                System.out.println("error!");
            }
        }
    }
}
